package com.xingshang.service.Proxy;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xingshang.mapper.AdminMapper;
import com.xingshang.model.po.Admin;
import com.xingshang.service.AdminLogService;
import com.xingshang.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceProxy extends ServiceImpl<AdminMapper, Admin>  implements AdminService {

    @Autowired
    @Qualifier("adminServiceImpl")
    private AdminService adminService;
    @Autowired
    private AdminLogService adminLogService;

    @Override
    public Admin findByAccountAndNotId(String account, Integer excludeId) {
        return adminService.findByAccountAndNotId(account, excludeId);
    }

    @Override
    public Admin login(String account, String password) {
// 记录登录日志
        adminLogService.logOperation("管理员", "登录", "管理员登录", true, "账号: " + account
                + ", 密码: " + password);
        //使用真实服务
        return adminService.login(account, password);
    }

    @Override
    public Admin findByAccount(String account) {
        return adminService.findByAccount(account);
    }

    @Override
    public Admin getUserByAccount(String account) {
        return adminService.getUserByAccount(account);
    }
}
